package com.weiai.wedding.entity.cases;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import com.weiai.wedding.util.ConUtils;

/**
 * 资源实体类
 * @author wangweiheng
 *
 */
@Entity
@Table(name="RESOURCES")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Resources {
	/**
	 * 资源ID
	 */
	private Long resourcesId;
	/**
	 * 资源名称
	 */
	private String resourcesName;
	/**
	 * 资源说明
	 */
	private String resourcesDesc;
	/**
	 * 资源路径
	 */
	private String resourcesDir;
	/**
	 * 创建时间
	 */
	private Date createTime;
	/**
	 * 创建人
	 */
	private String createBy;
	/**
	 * 类型
	 */
	private String resourcesType;
	/**
	 * 状态
	 */
	private String status;
	
	
	private String resourcesStr;
	
	private String createTimeStr;
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	public Long getResourcesId() {
		return resourcesId;
	}
	public void setResourcesId(Long resourcesId) {
		this.resourcesId = resourcesId;
	}
	
	@Column(nullable=false,length = 50)
	public String getResourcesName() {
		return resourcesName;
	}
	public void setResourcesName(String resourcesName) {
		this.resourcesName = resourcesName;
	}
	
	@Column(length=512)
	public String getResourcesDesc() {
		return resourcesDesc;
	}
	public void setResourcesDesc(String resourcesDesc) {
		this.resourcesDesc = resourcesDesc;
	}
	@Column(length=512)
	public String getResourcesDir() {
		return resourcesDir;
	}
	public void setResourcesDir(String resourcesDir) {
		this.resourcesDir = resourcesDir;
	}
	
	@Column(nullable=false)
	@Temporal(TemporalType.TIMESTAMP)
	public Date getCreateTime() {
		return createTime;
	}
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
		this.setCreateTimeStr(ConUtils.formatDate(createTime, "yyyy-MM-dd"));
	}
	
	@Column(nullable=false,length = 50)
	public String getCreateBy() {
		return createBy;
	}
	public void setCreateBy(String createBy) {
		this.createBy = createBy;
	}
	@Column(nullable=true,length = 5)
	public String getResourcesType() {
		return resourcesType;
	}
	public void setResourcesType(String resourcesType) {
		this.resourcesType = resourcesType;
		if("1".equals(resourcesType)){
			this.setResourcesStr("公共");
		}else if("2".equals(resourcesType)){
			this.setResourcesStr("私有");
		}
	}
	@Column(length=5)
	public String getStatus() {
		return status;
	}
	public void setStatus(String status) {
		this.status = status;
	}
	
	@Transient	
	public String getResourcesStr() {
		return resourcesStr;
	}
	public void setResourcesStr(String resourcesStr) {
		this.resourcesStr = resourcesStr;
	}
	@Transient	
	public String getCreateTimeStr() {
		return createTimeStr;
	}
	public void setCreateTimeStr(String createTimeStr) {
		this.createTimeStr = createTimeStr;
	}
	
	
}
